package com.wanmait.mpdemo;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    //设置静态资源的处理，请求路径和存放路径的对应关系
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // /static/uploadImages/1.jpg   => src/main/resources/static/uploadImages/1.jpg
        // /static/uploadImages/abc/12.jpg   => src/main/resources/static/uploadImages/abc/12.jpg
        registry.addResourceHandler("/static/uploadImages/**").addResourceLocations("classpath:/static/uploadImages/");
        // /uploadImages/1.jpg => D:/uploadImages/1.jpg
        //registry.addResourceHandler("/uploadImages/**").addResourceLocations("file:D:/uploadImages/");
    }
}
